/**
 * Created by Administrator on 2016/4/27 0027.
 */
document.write("<script language='javascript' src='/resources/js/views/defineTable.js'></script>");
document.write("<script language='javascript' src='/resources/js/load/loadArea.js'></script>");
document.write("<script language='javascript' src='/resources/js/load/loadIndicatorFromsType.js'></script>");
document.write("<script language='javascript' src='/resources/js/query/queryReportByAreaAndIndicator.js'></script>");

var years="../report/query/allYear.do";
var action_area_allCity = "/area/query/selfCity.do"; //-- 城市
var action_area_query_self = "/area/query/self.do";

var page_level="";
var city_html =
    '<label for="fieldAnalysis_citySelect">地市选择：</label>'
    +'<input name="fieldAnalysis_citySelect" id="fieldAnalysis_citySelect" class="w80 easyui-combobox">';
var county_html =
    '<label for="countySelect">区县选择：</label>'
    + '<input name="countySelect" id="countySelect" class="w120 easyui-combobox">';

var page = 1;
var pageSize = 30;
var ttIndicatorSelectCache= [];

function query() {
	queryByFormsInameAreaIndicatorType(page,pageSize,ENUM_AREA_COUNTY, ttIndicatorSelectCache);
}
function queryList() {
	queryByFormsInameAreaIndicators(page, pageSize,ENUM_AREA_COUNTY,ttIndicatorSelectCache);
}


//------------------------------------------------------------------菜单 start-------------------------------------------------------------
//获取用户所拥有的二级下拉列表菜单
function loadAreaView(){
    $.getJSON(action_area_query_self, function (json) {

        var code = json.code;
        if(code!=200){
            alert("网络不好啊！");
            return;
        }
        var data = json.data;
        var level = data.level;
        if(level === null){
            alert("用户权限配置不合理，请联系系统管理员！");
            return;
        }
        page_level = level;

        //画页面
        //根据不同的用户权限，控制用户页面显示几级菜单
        if(level=="province"||level=="city"){
            $("#insert_html").html(city_html+county_html);
			loadCityAndCountyDepart();
        }else if(level=="county"){
            $("#insert_html").html(county_html);
            //加载区县(只有区县权限的用户)下拉列表
            loadCounty(action_area_allCity, data.id);
        }
    }, "json");
}


var show = {
	tableshow:function () {
		this.a = !this.a 
		if(this.a)
			$("#tableView").panel("collapse",true);
		else
			$("#tableView").panel("expand",true);
	},
	photoshow:function () {
		this.b = !this.b 
		if(this.b){
			$("#annualAnalysis_chart").panel("collapse",true);
		}else{
			$("#annualAnalysis_chart").panel("expand",true);
		}
	}
}

// function queryByIndicatorType() {
// 	query(page,pageSize);
// 	var yeares = $('#comboboxYear').combobox('getText');
// 	var yearList = [];
// 	if(yeares!=null ||yeares!='' || yeares!=undefined){
// 		yearList=yeares.split(',');
// 	}
// 	showImage((yearList.length)-1);
// }

$(function(){

	ttIndicatorSelectCache=[];
	onlyLoadYear();
	loadFormAndOnlyIndicatorType();
    loadAreaView();

	$('#iname').textbox({prompt:'指标输入'});
	$("#tabDiv").css("height","60px !important");
	$('#tabDiv').tabs({
	    onSelect:function(title,index){
			if(index==0){
				var time= setTimeout(function(){
					showData(zbname, series, jsonXData,conceal,isShow);
				},10);
			}else if(index==1){
				var time= setTimeout(function(){
					$("#tabDiv").height("370px");
					var yeares=$('#comboboxYear').combobox('getText');
					var yearList= [];
					if(yeares!=null ||yeares!='' || yeares!=undefined){
						yearList=yeares.split(',');
					}
					showImage(yearList.length-1)
				},10);
			}
	    }
	});
});

function Save_Excel() {//导出Excel文件
	var grid = $("#annualAnalysis_tt");
	// var rows=grid.datagrid("getRowss");					  //获得表格行数据 getRowss
	var name='地市领域分析';
	var colums_all=grid.datagrid("options").columns;      		     //获得表格的所有列不包括冻结列
	var columses=[];
	var columss=[];
	for (var i = 1; i < colums_all[0].length; i++) {
		columss.push(colums_all[0][i]);
	}
	columses[0]=columss;
	var getSelections = grid.datagrid("getSelections");     //获得表格选中行数据 getSelections
	var obj = $.ExportExcelDlg({
		HeadInfo: columses,    //表头栏
		RowInfo: getSelections,		   //数据航
		FooterInfo: grid.datagrid("getFooterRows"),
		RowStart: 2,		   //导出行位置
		ColumStart: 2,		   //导出列位置
		SheetName: name,
		MainTitle: { Displayname: name, Alignment: 'Center' },
		SaveName: name,
		Swf: 'ExportExcel.swf'
	});
	obj.ExportExcelDlg('open');
}